package com.karl.mytask_2.tools;

import android.support.v4.app.FragmentActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Karl on 2016/5/27.
 */
public class FragmentActivityCollector {
    public  static List<FragmentActivity> fragmentActivities = new ArrayList<>();
    public static void addFragmentActivity(FragmentActivity fragmentActivity){
        fragmentActivities.add(fragmentActivity);
    }
    public static void removeFragmentActivity(FragmentActivity fragmentActivity){
        fragmentActivities.remove(fragmentActivity);
    }

    public static void finishAll(){
        for(FragmentActivity fragmentActivity : fragmentActivities){
            if (!fragmentActivity.isFinishing()){
                fragmentActivity.finish();
            }
        }
    }
}
